home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 4 / The 640 Meg Shareware Studio CD-ROM Volume IV (Data Express)(1994).ISO / clang / cenvid.zip / ISDAY_1.BAT < prev    next >
DOS Batch File  |  1993-03-18  |  2KB  |  40 lines

  1. @echo OFF
  2. REM IsDay_1.bat - Display message about whether it is The WeekDay requested, and set
  3. REM               ErrorLevel to 1 if it is else 0 if it is not
  4. cenvi %0.bat %1 %2
  5. GOTO CENVI_EXIT
  6.  
  7. main(argc,argv)
  8. {
  9.    IsDay = 0                           // Assume that it is not the correct day
  10.    if ( argc != 2  ||  strlen(argv[1]) < 3 ) {
  11.       // Invalid parameters were passed, and so explain how to use this program
  12.       ShowHelp()
  13.    } else {
  14.       TimeString = ctime(time())       // Standard C functions to get NOW as a string
  15.       strcpy(QueryDay,argv[1])         // copy first argument to work with it
  16.       QueryDay[3] = 0                  // limit to search on first three letters
  17.       // case-inensitive (i.e., both string converted to upper-case) search for
  18.       // QueryDay in TimeString
  19.       if strstr(strupr(TimeString),strupr(QueryDay)) {
  20.          printf("Yes, today is %s\n",argv[1])
  21.          IsDay = 1
  22.       } else
  23.          printf("No, today is not %s\n",argv[1])
  24.    }
  25.    return IsDay
  26. }
  27.  
  28. ShowHelp() // This routine is called above if input seems invalid
  29. {
  30.    printf("\n\a")      // This makes an audible beep
  31.    printf("IsDay.bat - CMM program to check if it is a certain day of the week.\n")
  32.    printf("            Will print messages if it is or isn't, and return with\n")
  33.    printf("            ERRORLEVEL 1 if it is the requested day, and 0 if it is not.\n")
  34.    printf("            You must supply at least the first three letters of the day.\n")
  35.    printf("Example:\n")
  36.    printf("\tISDAY <Friday | Fri | FRI | FRICASSE>\n\n");
  37. }
  38.  
  39. :CENVI_EXIT
  40.